# !/usr/bin python3
# encoding: utf-8 -*-
# @file     : person_page.py
# @author   : 沙陌 Matongxue_2
# @Time     : 2023/11/12 14:25
# @Copyright: 北京码同学
from pages.base_page import BuyerBasePage


class PersonCenterPage(BuyerBasePage):

    def click_address_menu(self):
        ele_info = self.page_eles['收货地址']
        self.operate.click(ele_info)
        return AddressPage()
    def click_my_order_menu(self):
        ele_info = self.page_eles['我的订单']
        self.operate.click(ele_info)
        return MyOrderPage()

class AddressPage(BuyerBasePage):
    def click_add_address(self):
        ele_info = self.page_eles['添加地址']
        self.operate.click(ele_info)
        return self
    def send_keys_name(self,name):
        ele_info = self.page_eles['收货人姓名']
        self.operate.send_keys(ele_info,name)
        return self
    def send_keys_mobile(self,mobile):
        ele_info = self.page_eles['联系方式']
        self.operate.send_keys(ele_info,mobile)
        return self
    def send_keys_detail_address(self,detail_address):
        ele_info = self.page_eles['详细地址']
        self.operate.send_keys(ele_info,detail_address)
        return self
    def send_keys_ship_address(self,ship_address):
        ele_info = self.page_eles['地址别名']
        self.operate.send_keys(ele_info,ship_address)
        return self
    def select_address(self):
        ele_info = self.page_eles['收货地址请选择']
        self.operate.move_to_element(ele_info)
        ele_info = {"name": "省", "type": "linktext", "value": "北京"}
        self.operate.click(ele_info)
        ele_info = {"name": "市", "type": "linktext", "value": "朝阳区"}
        self.operate.click(ele_info)
        ele_info = {"name": "区", "type": "linktext", "value": "三环以内"}
        self.operate.click(ele_info)
        return self
    def click_confirm_btn(self):
        ele_info = self.page_eles['确认按钮']
        self.operate.click(ele_info)
        return self

class MyOrderPage(BuyerBasePage):

    def send_keys_search(self,text):
        ele_info = self.page_eles['搜索输入框']
        self.operate.send_keys(ele_info,text)
        return self
    def click_search_btn(self):
        ele_info = self.page_eles['搜索按钮']
        self.operate.click(ele_info)
        return self
    def click_shouhuo_btn(self):
        ele_info = self.page_eles['确认收货']
        self.operate.click(ele_info)
        return self
    def click_confirm_btn(self):
        ele_info = self.page_eles['确定按钮']
        self.operate.click(ele_info)
        return self
    def click_comment(self):
        ele_info = self.page_eles['去评论']
        self.operate.click(ele_info)
        return MemberCommentPage()
    def click_after_sales(self):
        ele_info = self.page_eles['申请售后']
        self.operate.click(ele_info)
        return AfterSalesPage()

class AfterSalesPage(BuyerBasePage):

    def click_shenqing(self):
        ele_info = self.page_eles['申请']
        self.operate.click(ele_info)
        return self
    def click_returngoods(self):
        ele_info = self.page_eles['申请退货']
        self.operate.click(ele_info)
        return self
    def select_type(self,type_name='微信'):
        ele_info = self.page_eles['账户类型']
        self.operate.click(ele_info)
        ele_info = {"name":f"选择{type_name}","type":"xpath","value":f'//span[text()="{type_name}"]/..'}
        self.operate.click(ele_info)
        return self
    def send_keys_user(self,username):
        ele_info = self.page_eles['退款账号']
        self.operate.send_keys(ele_info,username)
        return self
    def select_reason(self,reason='质量问题'):
        ele_info = self.page_eles['提交原因']
        self.operate.click(ele_info)
        ele_info = {"name":f"选择{reason}","type":"xpath","value":f'//span[text()="{reason}"]/..'}
        self.operate.click(ele_info)
        return self
    def send_keys_content(self,text):
        ele_info = self.page_eles['问题描述']
        self.operate.send_keys(ele_info,text)
        return self
    def click_submit(self):
        ele_info = self.page_eles['确认提交']
        self.operate.click(ele_info)
        return self

class MemberCommentPage(BuyerBasePage):

    def click_level(self,level_name='好评'):
        ele_info = self.page_eles[level_name]
        self.operate.click(ele_info)
        return self
    def send_keys_content(self,text):
        ele_info = self.page_eles['评论内容']
        self.operate.send_keys(ele_info,text)
        return self
    def click_submit(self):
        ele_info = self.page_eles['发表评论']
        self.operate.click(ele_info)
        return self